#include"processBar.h"

#include<string.h>

#include<unistd.h>

#define GREEN "\033[0;32;32m"

#define END "\033[m"

const char* lable = "|/-\\";

void processbar(int speed)
{
    char bar[NUM];
    memset(bar, '\0', sizeof(bar));
    int cnt = 0;
    int len = strlen(lable);
    while(cnt<=TOP)
    {
        printf(GREEN"[%-100s]"END"[%d%%][%c]\r",bar,cnt,lable[cnt%len]);
        fflush(stdout);
        bar[cnt++] = BODY;
        if(cnt < TOP)
        {
            bar[cnt] = RIGHT;
        }        
        usleep(speed);
    }
    printf("\n");
}
